package com.varian.auth.authentication;

import cn.hutool.core.convert.Convert;
import com.varian.auth.service.IOAuth2RegisteredClientService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;

/**
 * @author ben
 * @since 2024/6/30
 */
@RequiredArgsConstructor
public class VarianRegisteredClientRepository implements RegisteredClientRepository {

    private final IOAuth2RegisteredClientService registeredClientService;

    @Override
    public void save(RegisteredClient registeredClient) {
    }

    @Override
    public RegisteredClient findById(String id) {
        return registeredClientService.findById(Convert.toLong(id));
    }

    @Override
    public RegisteredClient findByClientId(String clientId) {
        return registeredClientService.findByClientId(clientId);
    }
}
